#ifndef __INPUTMANAGER_H__
#define __INPUTMANAGER_H__

#include <map>
#include <string>
#include <list>
#include <set>
#include <SFML/Window.hpp>
#include "InputEvent.hpp"


class InputManager 
{
	public :
		static InputManager& instance();

		/** Note : If the input manager is already created, it will do nothing */
		static void createInstance(const sf::Input& input);
		static void destroyInstance();

		void update();
		void flushEvents();
		bool checkEvent(const InputEvent &event);
		sf::Vector2i posMouse() const;
		
	private :
		InputManager(const sf::Input& input);
		~InputManager();
		void bind();
		
		const sf::Input& m_input;
		std::map<std::string,sf::Key::Code> m_keys;
		std::map<std::string,sf::Mouse::Button> m_mouseButtons;

		std::set<std::string> m_pressedKeys;
		std::set<std::string> m_pressedMouseButtons;

		std::list<InputEvent> m_events;		
		
		static InputManager *m_inputManager;
};

#define CHECK_EVENT(event) InputManager::instance().checkEvent(event)

#endif /* __INPUTMANAGER_H__ */

